package com.hjx.http.util;

/**
 * Created by houjinxin on 2017/6/20.
 */
public class ProxyFetchUtil {

    private static final ThreadLocal<String[]> proxyThreadLocal = new ThreadLocal<String[]>();
    private static final ThreadLocal<Boolean> disableProxyThreadLocal = new ThreadLocal<Boolean>();

    public static String[] getProxyInfo(){
        return proxyThreadLocal.get();
    }

    public static void setProxyInfo(String[] proxyInfo){
        proxyThreadLocal.set(proxyInfo);
    }

    public static void disableProxy(){
        disableProxyThreadLocal.set(Boolean.TRUE);
    }

    public static void enableProxy(){
        disableProxyThreadLocal.set(Boolean.FALSE);
    }

    public static boolean isProxyDisabled(){
        return disableProxyThreadLocal.get() != null && disableProxyThreadLocal.get();
    }

    public static void remove(){
        proxyThreadLocal.remove();
        disableProxyThreadLocal.remove();
    }
}
